package io.e2x.testground.fruitstore.data;

import io.e2x.testground.fruitstore.dal.entities.Store;
import io.e2x.testground.fruitstore.dal.entities.User;
import lombok.Data;
import reactor.core.publisher.Mono;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 交易账单信息
 * @author: sukimiya
 * @date: 2020/5/27 16:01
 */
@Data
public class BillDTO {
    private String no;
    private long userId;
    private long storeId;
    private long orderId;
    /**
     * 订单优惠价格
     */
    private BigDecimal couponPrice;
    /**
     * 优惠券名称
     */
    private String couponName;
    /**
     * 订单减免价格
     */
    private BigDecimal discountPrice;
    /**
     * 订单实际支付价格
     */
    private BigDecimal payPrice;
    /**
     * 订单原价格
     */
    private BigDecimal price;
    /**
     * 订单项
     */
    private List<BillItemDTO> items = new ArrayList<>();
    /**
     * 店铺名称
     */
    private String StoreName;
    /**
     * 用户名称
     */
    private String UserName;

    public static Mono<BillDTO> build(Store store, User user) {
        BillDTO billDTO = new BillDTO();
        billDTO.no = "N" + System.currentTimeMillis();
        billDTO.storeId = store.getId();
        billDTO.userId = user.getId();
        billDTO.StoreName = store.getName();
        billDTO.UserName = user.getUsername();
        return Mono.just(billDTO);
    }
    @Override
    public String toString() {
        return "订单信息: {" +
                "订单编号='" + no + '\'' +
                ", 店铺名称='" + StoreName + '\'' +
                ", 用户ID=" + userId +
                ", 店铺ID=" + storeId +
                ", 订单ID=" + orderId +
                ", 优惠券抵扣=" + couponPrice +
                ", 优惠券名称='" + couponName + '\'' +
                ", 折扣价格=" + discountPrice +
                ", 实际支付=" + payPrice +
                ", 原价=" + price +
                ", 商品列表=" + items;

    }
}
